<!DOCTYPE html>
<html lang="zh-CN">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>接口调用日志记录完全指南</title>
    <link href="https://cdn.staticfile.org/font-awesome/6.4.0/css/all.min.css" rel="stylesheet">
    <link href="https://cdn.staticfile.org/tailwindcss/2.2.19/tailwind.min.css" rel="stylesheet">
    <link href="https://fonts.googleapis.com/css2?family=Noto+Serif+SC:wght@400;500;600;700&family=Noto+Sans+SC:wght@300;400;500;700&display=swap" rel="stylesheet">
    <script src="https://cdn.jsdelivr.net/npm/mermaid@latest/dist/mermaid.min.js"></script>
    <style>
        body {
            font-family: 'Noto Sans SC', Tahoma, Arial, Roboto, "Droid Sans", "Helvetica Neue", "Droid Sans Fallback", "Heiti SC", "Hiragino Sans GB", Simsun, sans-serif;
            background: linear-gradient(135deg, #f5f7fa 0%, #c3cfe2 100%);
            min-height: 100vh;
        }
        
        .hero-gradient {
            background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
        }
        
        .card-hover {
            transition: all 0.3s ease;
            border: 1px solid transparent;
        }
        
        .card-hover:hover {
            transform: translateY(-5px);
            box-shadow: 0 20px 40px rgba(0,0,0,0.1);
            border-color: #667eea;
        }
        
        .text-gradient {
            background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
            -webkit-background-clip: text;
            -webkit-text-fill-color: transparent;
            background-clip: text;
        }
        
        .code-block {
            background: #1e1e1e;
            color: #d4d4d4;
            border-radius: 12px;
            overflow: hidden;
            position: relative;
        }
        
        .code-block::before {
            content: '';
            position: absolute;
            top: 0;
            left: 0;
            right: 0;
            height: 40px;
            background: #2d2d2d;
            border-bottom: 1px solid #3e3e3e;
        }
        
        .code-dots {
            position: absolute;
            top: 12px;
            left: 15px;
            display: flex;
            gap: 8px;
        }
        
        .code-dot {
            width: 12px;
            height: 12px;
            border-radius: 50%;
        }
        
        .section-divider {
            height: 2px;
            background: linear-gradient(to right, transparent, #667eea, transparent);
            margin: 4rem 0;
        }
        
        .floating-icon {
            animation: float 3s ease-in-out infinite;
        }
        
        @keyframes float {
            0%, 100% { transform: translateY(0px); }
            50% { transform: translateY(-10px); }
        }
        
        .mermaid {
            display: flex;
            justify-content: center;
            margin: 2rem 0;
        }
        
        .drop-cap {
            float: left;
            font-size: 4rem;
            line-height: 1;
            font-weight: 700;
            margin-right: 0.5rem;
            margin-top: -0.2rem;
            color: #667eea;
            font-family: 'Noto Serif SC', serif;
        }
    </style>
</head>
<body>
    <!-- Hero Section -->
    <div class="hero-gradient text-white">
        <div class="container mx-auto px-6 py-20">
            <div class="max-w-4xl mx-auto text-center">
                <div class="floating-icon inline-block mb-6">
                    <i class="fas fa-file-alt text-6xl opacity-90"></i>
                </div>
                <h1 class="text-5xl md:text-6xl font-bold mb-6 leading-tight">
                    接口调用日志记录
                </h1>
                <p class="text-xl md:text-2xl opacity-90 leading-relaxed">
                    构建高效、可维护的系统监控体系
                </p>
                <div class="mt-8 flex justify-center space-x-4">
                    <span class="bg-white bg-opacity-20 px-4 py-2 rounded-full text-sm">
                        <i class="fas fa-bug mr-2"></i>调试排查
                    </span>
                    <span class="bg-white bg-opacity-20 px-4 py-2 rounded-full text-sm">
                        <i class="fas fa-tachometer-alt mr-2"></i>性能监控
                    </span>
                    <span class="bg-white bg-opacity-20 px-4 py-2 rounded-full text-sm">
                        <i class="fas fa-shield-alt mr-2"></i>安全审计
                    </span>
                </div>
            </div>
        </div>
    </div>

    <!-- Main Content -->
    <div class="container mx-auto px-6 py-12">
        <!-- Introduction -->
        <div class="max-w-4xl mx-auto mb-16">
            <div class="bg-white rounded-2xl shadow-xl p-8 md:p-12">
                <p class="text-lg leading-relaxed text-gray-700">
                    <span class="drop-cap">接</span>口调用的日志记录不仅是调试和排查问题的重要工具，还在性能监控、安全审计和业务分析中扮演着关键角色。通过选择合适的日志框架、设计合理的日志记录策略以及实施集中化日志管理，可以有效提高系统的可维护性、性能和安全性。
                </p>
            </div>
        </div>

        <!-- 日志记录的重要性 -->
        <section class="mb-16">
            <h2 class="text-4xl font-bold mb-8 text-center">
                <span class="text-gradient">日志记录的重要性</span>
            </h2>
            
            <div class="grid md:grid-cols-3 gap-6 mb-12">
                <div class="card-hover bg-white rounded-xl shadow-lg p-6">
                    <div class="text-purple-600 mb-4">
                        <i class="fas fa-tools text-4xl"></i>
                    </div>
                    <h3 class="text-xl font-bold mb-3">调试与排查</h3>
                    <ul class="space-y-2 text-gray-600">
                        <li><i class="fas fa-check-circle text-green-500 mr-2"></i>故障排查：追踪接口调用详细信息</li>
                        <li><i class="fas fa-check-circle text-green-500 mr-2"></i>调试信息：提供丰富的上下文信息</li>
                    </ul>
                </div>
                
                <div class="card-hover bg-white rounded-xl shadow-lg p-6">
                    <div class="text-purple-600 mb-4">
                        <i class="fas fa-chart-line text-4xl"></i>
                    </div>
                    <h3 class="text-xl font-bold mb-3">性能监控</h3>
                    <ul class="space-y-2 text-gray-600">
                        <li><i class="fas fa-check-circle text-green-500 mr-2"></i>性能分析：识别系统性能瓶颈</li>
                        <li><i class="fas fa-check-circle text-green-500 mr-2"></i>异常检测：发现异常模式和问题</li>
                    </ul>
                </div>
                
                <div class="card-hover bg-white rounded-xl shadow-lg p-6">
                    <div class="text-purple-600 mb-4">
                        <i class="fas fa-shield-alt text-4xl"></i>
                    </div>
                    <h3 class="text-xl font-bold mb-3">审计与合规</h3>
                    <ul class="space-y-2 text-gray-600">
                        <li><i class="fas fa-check-circle text-green-500 mr-2"></i>审计日志：确保业务规则合规</li>
                        <li><i class="fas fa-check-circle text-green-500 mr-2"></i>安全审计：监控安全相关事件</li>
                    </ul>
                </div>
            </div>
        </section>

        <div class="section-divider"></div>

        <!-- 日志记录的实现 -->
        <section class="mb-16">
            <h2 class="text-4xl font-bold mb-8 text-center">
                <span class="text-gradient">日志记录的实现</span>
            </h2>

            <!-- 日志框架选择 -->
            <div class="bg-white rounded-2xl shadow-xl p-8 mb-8">
                <h3 class="text-2xl font-bold mb-6 flex items-center">
                    <i class="fas fa-layer-group text-purple-600 mr-3"></i>
                    日志框架选择
                </h3>
                <div class="grid md:grid-cols-3 gap-6">
                    <div class="bg-gray-50 rounded-lg p-6">
                        <h4 class="font-bold text-lg mb-2 text-purple-700">Log4j</h4>
                        <p class="text-gray-600">经典的Java日志框架，支持多种日志级别和输出格式</p>
                    </div>
                    <div class="bg-gray-50 rounded-lg p-6">
                        <h4 class="font-bold text-lg mb-2 text-purple-700">SLF4J</h4>
                        <p class="text-gray-600">通用的日志接口，可与不同日志框架集成</p>
                    </div>
                    <div class="bg-gray-50 rounded-lg p-6">
                        <h4 class="font-bold text-lg mb-2 text-purple-700">Logback</h4>
                        <p class="text-gray-600">Log4j的继任者，提供更高性能和丰富功能</p>
                    </div>
                </div>
            </div>

            <!-- 日志记录策略 -->
            <div class="bg-white rounded-2xl shadow-xl p-8 mb-8">
                <h3 class="text-2xl font-bold mb-6 flex items-center">
                    <i class="fas fa-clipboard-list text-purple-600 mr-3"></i>
                    日志记录策略
                </h3>
                <div class="space-y-4">
                    <div class="flex items-start">
                        <i class="fas fa-level-up-alt text-purple-600 mt-1 mr-3"></i>
                        <div>
                            <h4 class="font-bold mb-1">日志级别</h4>
                            <p class="text-gray-600">根据重要性选择合适的日志级别：DEBUG、INFO、WARN、ERROR</p>
                        </div>
                    </div>
                    <div class="flex items-start">
                        <i class="fas fa-code text-purple-600 mt-1 mr-3"></i>
                        <div>
                            <h4 class="font-bold mb-1">日志格式</h4>
                            <p class="text-gray-600">配置包含时间戳、线程ID、类名、方法名和日志消息的格式</p>
                        </div>
                    </div>
                    <div class="flex items-start">
                        <i class="fas fa-database text-purple-600 mt-1 mr-3"></i>
                        <div>
                            <h4 class="font-bold mb-1">日志存储</h4>
                            <p class="text-gray-600">选择合适的存储方式：文件、数据库或远程日志服务</p>
                        </div>
                    </div>
                </div>
            </div>

            <!-- 最佳实践 -->
            <div class="bg-gradient-to-r from-purple-50 to-pink-50 rounded-2xl p-8 mb-8">
                <h3 class="text-2xl font-bold mb-6 flex items-center">
                    <i class="fas fa-star text-purple-600 mr-3"></i>
                    日志记录的最佳实践
                </h3>
                <div class="grid md:grid-cols-3 gap-6">
                    <div class="bg-white rounded-lg p-6 shadow">
                        <i class="fas fa-info-circle text-3xl text-purple-600 mb-3"></i>
                        <h4 class="font-bold mb-2">上下文信息</h4>
                        <p class="text-gray-600 text-sm">记录请求ID、用户ID、接口参数等关键信息</p>
                    </div>
                    <div class="bg-white rounded-lg p-6 shadow">
                        <i class="fas fa-user-shield text-3xl text-purple-600 mb-3"></i>
                        <h4 class="font-bold mb-2">敏感信息保护</h4>
                        <p class="text-gray-600 text-sm">避免记录密码、信用卡号等敏感数据</p>
                    </div>
                    <div class="bg-white rounded-lg p-6 shadow">
                        <i class="fas fa-sync text-3xl text-purple-600 mb-3"></i>
                        <h4 class="font-bold mb-2">异步日志记录</h4>
                        <p class="text-gray-600 text-sm">提高性能，减少对主线程的影响</p>
                    </div>
                </div>
            </div>
        </section>

        <div class="section-divider"></div>

        <!-- 实现示例 -->
        <section class="mb-16">
            <h2 class="text-4xl font-bold mb-8 text-center">
                <span class="text-gradient">实现接口调用日志记录</span>
            </h2>

            <!-- Spring Boot 拦截器实现 -->
            <div class="mb-12">
                <h3 class="text-2xl font-bold mb-6 flex items-center">
                    <i class="fas fa-code text-purple-600 mr-3"></i>